package UMC.Web;

import UMC.Data.IJSON;

import java.util.LinkedList;
import java.util.List;

public class UISheetDialog extends UIDialog {
    List<IJSON> _nSource = new LinkedList<>();

    public int size() {

        return _nSource.size();
    }

    public UISheetDialog put(UIClick click) {
        _nSource.add(click);
        return this;
    }

    public UISheetDialog put(String text, String value) {
        _nSource.add(new ListItem(text, value));
        return this;
    }

    public UISheetDialog put(ListItem item) {
        _nSource.add(item);
        return this;
    }

    protected void initialization(WebContext context) {

        this.config.put("DataSource", _nSource);
        super.initialization(context);
    }

    public void action(UIClick value) {
        this.config.put("Action", value);
    }

    public void action(boolean value) {

        if (value) {
            this.config.put("Action", true);
        } else {
            this.config.remove("Action");
        }
    }

    @Override
    protected String type() {
        return "Select";
    }

}
